package com.sgu6.sgu6_machine.ui.fragment.set;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.sgu6.middleware.enums.MachineCmdEnum;
import com.sgu6.middleware.util.HexUtil;
import com.sgu6.serialport.manager.SerialPortManager;
import com.sgu6.sgu6_machine.R;
import com.sgu6.sgu6_machine.base.BaseF;
import com.sgu6.sgu6_machine.config.MachineConfig;
import com.sgu6.sgu6_machine.config.McDefaultConfig;
import com.sgu6.sgu6_machine.container.MachineContainer;
import com.sgu6.sgu6_machine.ui.views.AmountView;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 警报设置
 */
public class WarningF extends BaseF {

    @BindView(R.id.tvOverheatValue)
    TextView tvOverheatValue;
    @BindView(R.id.atTempOverHeat)
    AmountView atTempOverHeat;
    @BindView(R.id.tvHeatOverTimeValue)
    TextView tvHeatOverTimeValue;
    @BindView(R.id.atHeatOverTime)
    AmountView atHeatOverTime;
    @BindView(R.id.tvMillOverTimeValue)
    TextView tvMillOverTimeValue;
    @BindView(R.id.atMillOverTime)
    AmountView atMillOverTime;
    @BindView(R.id.tvCookOverTimeValue)
    TextView tvCookOverTimeValue;
    @BindView(R.id.atCookOverTime)
    AmountView atCookOverTime;
    @BindView(R.id.tvPullMoOverTimeValue)
    TextView tvPullMoOverTimeValue;
    @BindView(R.id.atPullMoOverTime)
    AmountView atPullMoOverTime;
    @BindView(R.id.tvSealMoOverTimeValue)
    TextView tvSealMoOverTimeValue;
    @BindView(R.id.atSealMoOverTime)
    AmountView atSealMoOverTime;
    @BindView(R.id.tvSendValleyOverTimeValue)
    TextView tvSendValleyOverTimeValue;
    @BindView(R.id.atSendValleyOverTime)
    AmountView atSendValleyOverTime;
    @BindView(R.id.tvSendValleyKeepTimeValue)
    TextView tvSendValleyKeepTimeValue;
    @BindView(R.id.atSendValleyKeepTime)
    AmountView atSendValleyKeepTime;
    @BindView(R.id.tvSendMoOverTimeValue)
    TextView tvSendMoOverTimeValue;
    @BindView(R.id.atSendMoOverTime)
    AmountView atSendMoOverTime;
    @BindView(R.id.tvBranFullOverTimeValue)
    TextView tvBranFullOverTimeValue;
    @BindView(R.id.atBranFullOverTime)
    AmountView atBranFullOverTime;
    @BindView(R.id.tvMaxSteps)
    TextView tvMaxSteps;
    @BindView(R.id.atMaxRecoverySteps)
    AmountView atMaxRecoverySteps;
    @BindView(R.id.ll_temp)
    LinearLayout llTemp;
    @BindView(R.id.ll_heat)
    LinearLayout llHeat;
    @BindView(R.id.ll_pullmo)
    LinearLayout llPullmo;
    @BindView(R.id.ll_sealmo)
    LinearLayout llSealmo;
    @BindView(R.id.ll_sendmo)
    LinearLayout llSendmo;

    List<String> defaultCmd = new ArrayList<>(); //存放默认值的命令
    int index = 0;//全部恢复默认值命令下标

    Thread thread;
    Timer timer = new Timer();

    Unbinder unbinder;


    public static WarningF newInstance() {
        return new WarningF();
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_warnning, container, false);
        unbinder = ButterKnife.bind(this, v);

        initParams();

        initWarningValue();

        initUI();

        return v;
    }

    public void initUI() {
        atSendValleyKeepTime.setDefaultValue(MachineContainer.machineConfigDto.sendValleyKeepTime);
        atSendValleyKeepTime.setAmountMaxValue(60);

        atTempOverHeat.setDefaultValue(MachineContainer.machineConfigDto.tempOver);

        atHeatOverTime.setDefaultValue(MachineContainer.machineConfigDto.heatTimeOut);

        atMillOverTime.setDefaultValue(MachineContainer.machineConfigDto.millTimeOut);

        atCookOverTime.setDefaultValue(MachineContainer.machineConfigDto.dropTimeOut);

        atPullMoOverTime.setDefaultValue(MachineContainer.machineConfigDto.pullMoTimeOut);

        atSealMoOverTime.setDefaultValue(MachineContainer.machineConfigDto.sealMoTimeOut);

        atSendValleyOverTime.setDefaultValue(MachineContainer.machineConfigDto.sendValleyTimeOut);

        atSendMoOverTime.setDefaultValue(MachineContainer.machineConfigDto.sendMoTimeOut);

        atBranFullOverTime.setDefaultValue(MachineContainer.machineConfigDto.branFullTimeOut);

        atMaxRecoverySteps.setDefaultValue(MachineContainer.machineConfigDto.maxResetSteps);

    }

    private void initWarningValue() {
        tvSendValleyKeepTimeValue.setText(String.valueOf(MachineContainer.machineConfigDto.sendValleyKeepTime));
        tvOverheatValue.setText(String.valueOf(MachineContainer.machineConfigDto.tempOver));
        tvHeatOverTimeValue.setText(String.valueOf(MachineContainer.machineConfigDto.heatTimeOut));
        tvMillOverTimeValue.setText(String.valueOf(MachineContainer.machineConfigDto.millTimeOut));
        tvCookOverTimeValue.setText(String.valueOf(MachineContainer.machineConfigDto.dropTimeOut));
        tvPullMoOverTimeValue.setText(String.valueOf(MachineContainer.machineConfigDto.pullMoTimeOut));
        tvSealMoOverTimeValue.setText(String.valueOf(MachineContainer.machineConfigDto.sealMoTimeOut));
        tvSendValleyOverTimeValue.setText(String.valueOf(MachineContainer.machineConfigDto.sendValleyTimeOut));
        tvSendMoOverTimeValue.setText(String.valueOf(MachineContainer.machineConfigDto.sendMoTimeOut));
        tvBranFullOverTimeValue.setText(String.valueOf(MachineContainer.machineConfigDto.branFullTimeOut));
        tvMaxSteps.setText(String.valueOf(MachineContainer.machineConfigDto.maxResetSteps));
    }

    private void initParams() {
        defaultCmd.add(MachineCmdEnum.送谷保持时间默认.code());
        defaultCmd.add(MachineCmdEnum.温度超温警报默认.code());
        defaultCmd.add(MachineCmdEnum.加热超时警报默认.code());
        defaultCmd.add(MachineCmdEnum.碾米超时警报默认.code());
        defaultCmd.add(MachineCmdEnum.下米超时警报默认.code());
        defaultCmd.add(MachineCmdEnum.拉膜超时警报默认.code());
        defaultCmd.add(MachineCmdEnum.封膜超时警报默认.code());
        defaultCmd.add(MachineCmdEnum.送谷超时警报默认.code());
        defaultCmd.add(MachineCmdEnum.送膜超时警报默认.code());
        defaultCmd.add(MachineCmdEnum.糠满超时警报默认.code());
        defaultCmd.add(MachineCmdEnum.精度电机最大复位步数警报默认.code());
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
        thread = null;
        timer = null;
    }

    @OnClick({R.id.btnSetSendValleyKeepTime, R.id.btnRecoverySendValleyKeepTimeDefault, R.id.btnSetTempOverHeat, R.id.btnRecoveryTempOverHeatDefault, R.id.btnSetHeatOverTime, R.id.btnRecoveryHeatOverTimeDefault, R.id.btnSetMillOverTime, R.id.btnRecoveryMillOverTimeDefault, R.id.btnSetCookOverTime, R.id.btnRecoveryCookOverTimeDefault, R.id.btnSetPullMoOverTime, R.id.btnRecoveryPullMoOverTimeDefault, R.id.btnSetSealMoOverTime, R.id.btnRecoverySealMoOverTimeDefault, R.id.btnSetSendValleyOverTime, R.id.btnRecoverySendValleyOverTimeDefault, R.id.btnSetSendMoOverTime, R.id.btnRecoverySendMoOverTimeDefault, R.id.btnSetBranFullOverTime, R.id.btnRecoveryBranFullOverTimeDefault, R.id.btnSetMaxSteps, R.id.btnRecoveryMaxStepsDefault, R.id.btnAllRecoveryDefault})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btnSetSendValleyKeepTime:
                String svk = String.format(MachineCmdEnum.送谷保持时间.code(), atSendValleyKeepTime.getValue() * 10);
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(svk))) {
                    tvSendValleyKeepTimeValue.setText(String.valueOf(atSendValleyKeepTime.getValue()));
                    MachineContainer.machineConfigDto.sendValleyKeepTime = (atSendValleyKeepTime.getValue());
                    updateMachineInfo();
                }
                break;
            case R.id.btnRecoverySendValleyKeepTimeDefault:
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(MachineCmdEnum.送谷保持时间默认.code()))) {
                    atSendValleyKeepTime.setDefaultValue(McDefaultConfig.DEFAULT_SEND_VALLEY_KEEP_VALUE);
                    tvSendValleyKeepTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_SEND_VALLEY_KEEP_VALUE));
                    MachineContainer.machineConfigDto.sendValleyKeepTime = (McDefaultConfig.DEFAULT_SEND_VALLEY_KEEP_VALUE);
                    updateMachineInfo();
                }
                break;
            case R.id.btnSetTempOverHeat:
                String toc = String.format(MachineCmdEnum.温度超温警报.code(), atTempOverHeat.getValue() * 10);
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(toc))) {
                    tvOverheatValue.setText(String.valueOf(atTempOverHeat.getValue()));
                    MachineContainer.machineConfigDto.tempOver = (atTempOverHeat.getValue());
                    updateMachineInfo();
                }
                break;
            case R.id.btnRecoveryTempOverHeatDefault:
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(MachineCmdEnum.温度超温警报默认.code()))) {
                    atTempOverHeat.setDefaultValue(McDefaultConfig.DEFAULT_OVER_TEMP_VALUE);
                    tvOverheatValue.setText(String.valueOf(McDefaultConfig.DEFAULT_OVER_TEMP_VALUE));
                    MachineContainer.machineConfigDto.tempOver = (McDefaultConfig.DEFAULT_OVER_TEMP_VALUE);
                    updateMachineInfo();
                }
                break;
            case R.id.btnSetHeatOverTime:
                String hot = String.format(MachineCmdEnum.加热超时警报.code(), atHeatOverTime.getValue() * 10);
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(hot)))
                    tvHeatOverTimeValue.setText(String.valueOf(atHeatOverTime.getValue()));
                MachineContainer.machineConfigDto.heatTimeOut = (atHeatOverTime.getValue());
                updateMachineInfo();
                break;
            case R.id.btnRecoveryHeatOverTimeDefault:
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(MachineCmdEnum.加热超时警报默认.code()))) {
                    atHeatOverTime.setDefaultValue(McDefaultConfig.DEFAULT_HEAT_TIMEOUT_VALUE);
                    tvHeatOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_HEAT_TIMEOUT_VALUE));
                    MachineContainer.machineConfigDto.heatTimeOut = (McDefaultConfig.DEFAULT_HEAT_TIMEOUT_VALUE);
                    updateMachineInfo();
                }
                break;
            case R.id.btnSetMillOverTime:
                String mot = String.format(MachineCmdEnum.碾米超时警报.code(), atMillOverTime.getValue() * 10);
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(mot))) {
                    tvMillOverTimeValue.setText(String.valueOf(atMillOverTime.getValue()));
                    MachineContainer.machineConfigDto.millTimeOut = (atMillOverTime.getValue());
                    updateMachineInfo();
                }
                break;

            case R.id.btnRecoveryMillOverTimeDefault:
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(MachineCmdEnum.碾米超时警报默认.code()))) {
                    atMillOverTime.setDefaultValue(McDefaultConfig.DEFAULT_MILL_TIMEOUT_VALUE);
                    tvMillOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_MILL_TIMEOUT_VALUE));
                    MachineContainer.machineConfigDto.millTimeOut = (McDefaultConfig.DEFAULT_MILL_TIMEOUT_VALUE);
                    updateMachineInfo();
                }
                break;
            case R.id.btnSetCookOverTime:
                String cot = String.format(MachineCmdEnum.下米超时警报.code(), atCookOverTime.getValue() * 10);
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(cot)))
                    tvCookOverTimeValue.setText(String.valueOf(atCookOverTime.getValue()));
                MachineContainer.machineConfigDto.dropTimeOut = (atCookOverTime.getValue());
                updateMachineInfo();
//                thread = new Thread(() -> WarningUtil.getInstance(getActivity()).add(MachineCmdEnum.下米超时警报.code(), String.valueOf(atCookOverTime.getValue())));
//                thread.start();
                break;

            case R.id.btnRecoveryCookOverTimeDefault:
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(MachineCmdEnum.下米超时警报默认.code()))) {
                    atCookOverTime.setDefaultValue(McDefaultConfig.DEFAULT_DROP_TIMEOUT_VALUE);
                    tvCookOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_DROP_TIMEOUT_VALUE));
                    MachineContainer.machineConfigDto.dropTimeOut = (McDefaultConfig.DEFAULT_DROP_TIMEOUT_VALUE);
                    updateMachineInfo();
                }
                break;
            case R.id.btnSetPullMoOverTime:
                String pot = String.format(MachineCmdEnum.拉膜超时警报.code(), atPullMoOverTime.getValue() * 10);
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(pot))) {
                    tvPullMoOverTimeValue.setText(String.valueOf(atPullMoOverTime.getValue()));
                    MachineContainer.machineConfigDto.pullMoTimeOut = (atPullMoOverTime.getValue());
                    updateMachineInfo();
                }
                break;

            case R.id.btnRecoveryPullMoOverTimeDefault:
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(MachineCmdEnum.拉膜超时警报默认.code()))) {
                    atPullMoOverTime.setDefaultValue(McDefaultConfig.DEFAULT_PULL_TIMEOUT_VALUE);
                    tvPullMoOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_PULL_TIMEOUT_VALUE));
                    MachineContainer.machineConfigDto.pullMoTimeOut = (McDefaultConfig.DEFAULT_PULL_TIMEOUT_VALUE);
                    updateMachineInfo();
                }
                break;
            case R.id.btnSetSealMoOverTime:
                String sot = String.format(MachineCmdEnum.封膜超时警报.code(), atSealMoOverTime.getValue() * 10);
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(sot))) {
                    tvSealMoOverTimeValue.setText(String.valueOf(atSealMoOverTime.getValue()));
                    MachineContainer.machineConfigDto.sealMoTimeOut = (atSealMoOverTime.getValue());
                    updateMachineInfo();
                }
                break;
            case R.id.btnRecoverySealMoOverTimeDefault:
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(MachineCmdEnum.封膜超时警报默认.code()))) {
                    atSealMoOverTime.setDefaultValue(McDefaultConfig.DEFAULT_PULL_TIMEOUT_VALUE);
                    tvSealMoOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_SEAL_TIMEOUT_VALUE));
                    MachineContainer.machineConfigDto.sealMoTimeOut = (McDefaultConfig.DEFAULT_SEAL_TIMEOUT_VALUE);
                    updateMachineInfo();
                }
                break;
            case R.id.btnSetSendValleyOverTime:
                String svot = String.format(MachineCmdEnum.送谷超时警报.code(), atSendValleyOverTime.getValue() * 10);
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(svot))) {
                    tvSendValleyOverTimeValue.setText(String.valueOf(atSendValleyOverTime.getValue()));
                    MachineContainer.machineConfigDto.sendValleyTimeOut = (atSendValleyOverTime.getValue());
                    updateMachineInfo();
                }
                break;
            case R.id.btnRecoverySendValleyOverTimeDefault:
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(MachineCmdEnum.送谷超时警报默认.code()))) {
                    atSendValleyOverTime.setDefaultValue(McDefaultConfig.DEFAULT_SEND_VALLEY_TIMEOUT_VALUE);
                    tvSendValleyOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_SEND_VALLEY_TIMEOUT_VALUE));
                    MachineContainer.machineConfigDto.sendValleyTimeOut = (McDefaultConfig.DEFAULT_SEND_VALLEY_TIMEOUT_VALUE);
                    updateMachineInfo();
                }
                break;
            case R.id.btnSetSendMoOverTime:
                String smot = String.format(MachineCmdEnum.送膜超时警报.code(), atSendMoOverTime.getValue() * 10);
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(smot))) {
                    tvSendMoOverTimeValue.setText(String.valueOf(atSendMoOverTime.getValue()));
                    MachineContainer.machineConfigDto.sendMoTimeOut = (atSendMoOverTime.getValue());
                    updateMachineInfo();
                }
                break;
            case R.id.btnRecoverySendMoOverTimeDefault:
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(MachineCmdEnum.送膜超时警报默认.code()))) {
                    atSendMoOverTime.setDefaultValue(McDefaultConfig.DEFAULT_SEND_MO_TIMEOUT_VALUE);
                    tvSendMoOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_SEND_MO_TIMEOUT_VALUE));
                    MachineContainer.machineConfigDto.sendMoTimeOut = (McDefaultConfig.DEFAULT_SEND_MO_TIMEOUT_VALUE);
                    updateMachineInfo();
                }
                break;
            case R.id.btnSetBranFullOverTime:
                String bfot = String.format(MachineCmdEnum.糠满超时警报.code(), atBranFullOverTime.getValue());
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(bfot))) {
                    tvBranFullOverTimeValue.setText(String.valueOf(atBranFullOverTime.getValue()));
                    MachineContainer.machineConfigDto.branFullTimeOut = (atBranFullOverTime.getValue());
                    updateMachineInfo();
                }
                break;
            case R.id.btnRecoveryBranFullOverTimeDefault:
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(MachineCmdEnum.糠满超时警报默认.code()))) {
                    atBranFullOverTime.setDefaultValue(McDefaultConfig.DEFAULT_BRAN_FULL_TIMEOUT_VALUE);
                    tvBranFullOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_BRAN_FULL_TIMEOUT_VALUE));
                    MachineContainer.machineConfigDto.branFullTimeOut = (McDefaultConfig.DEFAULT_BRAN_FULL_TIMEOUT_VALUE);
                    updateMachineInfo();
                }
                break;
            case R.id.btnSetMaxSteps:
                String ms = String.format(MachineCmdEnum.精度电机最大复位步数警报.code(), atMaxRecoverySteps.getValue());
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(ms))) {
                    tvMaxSteps.setText(String.valueOf(atMaxRecoverySteps.getValue()));
                    MachineContainer.machineConfigDto.maxResetSteps = (atMaxRecoverySteps.getValue());
                    updateMachineInfo();
                }
                break;
            case R.id.btnRecoveryMaxStepsDefault:
                if (SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(MachineCmdEnum.精度电机最大复位步数警报默认.code()))) {
                    atMaxRecoverySteps.setDefaultValue(McDefaultConfig.DEFAULT_MAX_RECOVERY_STEPS_VALUE);
                    tvMaxSteps.setText(String.valueOf(McDefaultConfig.DEFAULT_MAX_RECOVERY_STEPS_VALUE));
                    MachineContainer.machineConfigDto.maxResetSteps = (McDefaultConfig.DEFAULT_MAX_RECOVERY_STEPS_VALUE);
                    updateMachineInfo();
                }
                break;
            case R.id.btnAllRecoveryDefault:
                atTempOverHeat.setDefaultValue(McDefaultConfig.DEFAULT_OVER_TEMP_VALUE);
                atSendValleyKeepTime.setDefaultValue(McDefaultConfig.DEFAULT_SEND_VALLEY_KEEP_VALUE);
                atHeatOverTime.setDefaultValue(McDefaultConfig.DEFAULT_HEAT_TIMEOUT_VALUE);
                atMillOverTime.setDefaultValue(McDefaultConfig.DEFAULT_MILL_TIMEOUT_VALUE);
                atCookOverTime.setDefaultValue(McDefaultConfig.DEFAULT_DROP_TIMEOUT_VALUE);
                atPullMoOverTime.setDefaultValue(McDefaultConfig.DEFAULT_PULL_TIMEOUT_VALUE);
                atSealMoOverTime.setDefaultValue(McDefaultConfig.DEFAULT_SEAL_TIMEOUT_VALUE);
                atSendValleyOverTime.setDefaultValue(McDefaultConfig.DEFAULT_SEND_VALLEY_TIMEOUT_VALUE);
                atSendMoOverTime.setDefaultValue(McDefaultConfig.DEFAULT_SEND_MO_TIMEOUT_VALUE);
                atBranFullOverTime.setDefaultValue(McDefaultConfig.DEFAULT_BRAN_FULL_TIMEOUT_VALUE);
                atMaxRecoverySteps.setDefaultValue(McDefaultConfig.DEFAULT_MAX_RECOVERY_STEPS_VALUE);
                timer.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        if (index < 10) {
                            SerialPortManager.getInstance().sendBytes(HexUtil.HexString2Bytes(defaultCmd.get(index)));
                            index++;
                        } else {
                            getActivity().runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    recoveryDefaultWarningValue();
                                }
                            });
                            index = 0;
                            cancel();
                        }

                    }
                }, 500, 1000);

                break;
        }

    }

    /**
     * 电机默认报警值
     */
    private void recoveryDefaultWarningValue() {

        tvOverheatValue.setText(String.valueOf(McDefaultConfig.DEFAULT_OVER_TEMP_VALUE));

        tvSendValleyKeepTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_SEND_VALLEY_KEEP_VALUE));

        tvHeatOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_HEAT_TIMEOUT_VALUE));

        tvMillOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_MILL_TIMEOUT_VALUE));

        tvCookOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_DROP_TIMEOUT_VALUE));

        tvPullMoOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_PULL_TIMEOUT_VALUE));

        tvSealMoOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_SEAL_TIMEOUT_VALUE));

        tvSendValleyOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_SEND_VALLEY_TIMEOUT_VALUE));

        tvSendMoOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_SEND_MO_TIMEOUT_VALUE));

        tvBranFullOverTimeValue.setText(String.valueOf(McDefaultConfig.DEFAULT_BRAN_FULL_TIMEOUT_VALUE));

        tvMaxSteps.setText(String.valueOf(McDefaultConfig.DEFAULT_MAX_RECOVERY_STEPS_VALUE));

        MachineContainer.machineConfigDto.sendValleyKeepTime = (McDefaultConfig.DEFAULT_SEND_VALLEY_KEEP_VALUE);
        MachineContainer.machineConfigDto.tempOver = (McDefaultConfig.DEFAULT_OVER_TEMP_VALUE);
        MachineContainer.machineConfigDto.heatTimeOut = (McDefaultConfig.DEFAULT_HEAT_TIMEOUT_VALUE);
        MachineContainer.machineConfigDto.millTimeOut = (McDefaultConfig.DEFAULT_MILL_TIMEOUT_VALUE);
        MachineContainer.machineConfigDto.dropTimeOut = (McDefaultConfig.DEFAULT_DROP_TIMEOUT_VALUE);
        MachineContainer.machineConfigDto.pullMoTimeOut = (McDefaultConfig.DEFAULT_PULL_TIMEOUT_VALUE);
        MachineContainer.machineConfigDto.sealMoTimeOut = (McDefaultConfig.DEFAULT_SEAL_TIMEOUT_VALUE);
        MachineContainer.machineConfigDto.sendValleyTimeOut = (McDefaultConfig.DEFAULT_SEND_VALLEY_TIMEOUT_VALUE);
        MachineContainer.machineConfigDto.sendMoTimeOut = (McDefaultConfig.DEFAULT_SEND_MO_TIMEOUT_VALUE);
        MachineContainer.machineConfigDto.branFullTimeOut = (McDefaultConfig.DEFAULT_BRAN_FULL_TIMEOUT_VALUE);
        MachineContainer.machineConfigDto.maxResetSteps = (McDefaultConfig.DEFAULT_MAX_RECOVERY_STEPS_VALUE);
        updateMachineInfo();
    }


    private void updateMachineInfo() {
       updateConfig();
    }

}
